package org.millioncall.yueyoga.admin.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.millioncall.openplatform.common.PaginatedList;
import org.millioncall.yueyoga.admin.dao.MemberLevelDAO;
import org.millioncall.yueyoga.admin.model.MemberLevel;
import org.millioncall.yueyoga.admin.service.MemberLevelService;
import org.springframework.stereotype.Service;

@Service
public class MemberLevelServiceImpl implements MemberLevelService {
	private static final Logger logger = LoggerFactory.getLogger(MemberLevel.class);
	private MemberLevelDAO memberLevelDAO;

	public MemberLevelDAO getMemberLevelDAO() {
		return memberLevelDAO;
	}

	public void setMemberLevelDAO(MemberLevelDAO memberLevelDAO) {
		this.memberLevelDAO = memberLevelDAO;
	}

	@Override
	public PaginatedList<MemberLevel> getMemberLevelInPage(int start, int pageSize) {
		PaginatedList<MemberLevel> p=memberLevelDAO.findPage(start,pageSize);
		return p;
	}

	@Override
	public void deleteMemberLevelByIds(Integer[] deids) {
		if(deids == null || deids.length == 0) {
			logger.error("未提交要删除演讲者的编号");
			throw new RuntimeException(" 未提交要删除演讲者的编号");
		} else {
			this.memberLevelDAO.deleteByIds(deids);
		}
	}
	
	@Override
	public boolean saveMemberLevel(Map<String, Object> map) {
		int i=memberLevelDAO.save(map);
		if(i>0){
			return true;
		}else{
			return false;
		}
	}

	@Override
	public boolean updateMemberLevel(Map<String, Object> map) {
		int i=memberLevelDAO.update(map);
		if(i>0){
			return true;
		}else{
			return false;
		}
	}

	@Override
	public MemberLevel findById(Integer id) {
		return memberLevelDAO.findById(id);
	}

	@Override
	public List<MemberLevel> findMemberLevel() {
		// TODO Auto-generated method stub
		return memberLevelDAO.getMemberLevelByEnable();
	}
}
